package DemoApi;

import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class test1 {
    public static void main(String[] args) {
        //jdk8之前那个SimpleDateFormat
        Date d=new Date();
        System.out.println(d);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEE a");
        String result=sdf.format(d);
        System.out.println(result);
        //jdk8之后的LocalDateTime
        LocalDateTime now = LocalDateTime.now();
        System.out.println("新的时间"+now);
        System.out.println("新的时间"+now.getYear());
        DateTimeFormatter dnf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss EEE a");
        System.out.println("新的时间也要格式化:"+dnf.format(now));
    }
}
